<?php
    cria_variaveis($_POST,$_GET,$_FILES); 
?>
<p class="titulo" align="center"><?php echo $msg->get("SUBPF_MSG_02") ?></p>
<p class="subtitulo" align="center"><?php echo $msg->get("SUBPF_MSG_03") ?></p>
<p>
<div class="tabbar">
    <ul>
    <li><a href="index.php?inc=subtracaoPF.php&modo=material"<?php if ($_SESSION['ANAWEB']->RetornaModoExecucao() == "material") echo " class=\"tabact\""; ?>><?php echo $msg->get("Material_Teorico"); ?></a></li>
    <li><a href="index.php?inc=subtracaoPF.php&modo=exemplo"<?php if ($_SESSION['ANAWEB']->RetornaModoExecucao() == "exemplo") echo " class=\"tabact\""; ?>><?php echo $msg->get("Exemplos_Prontos"); ?></a></li>
    <li><a href="index.php?inc=subtracaoPF.php&modo=teclado"<?php if ($_SESSION['ANAWEB']->RetornaModoExecucao() == "teclado") echo " class=\"tabact\""; ?>><?php echo $msg->get("Entrada_Teclado"); ?></a></li>
    </ul>
</div>
<div id="cas">
<?php
if (!isset($Calcular)) {		
    if ($_SESSION['ANAWEB']->RetornaModoExecucao() == "material")
    {
        require_once("./classes/upload.php");
        $uploads = new Upload();
        $uploads->Lista("ptoflut");
    }
    else if ($_SESSION['ANAWEB']->RetornaModoExecucao() == "exemplo") { //leitura de dados via banco de dados - modulo de exemplos e exercicios
        include "exibe_prob_ptoflut_subtracao_xml.php";
	}
	else if ($_SESSION['ANAWEB']->RetornaModoExecucao() == "teclado") {
		if ( (strlen($base)==0)or($base<2)or($base>10)or(strlen($casas)==0)or($casas<1)or(strlen($expmin)==0)or(strlen($expmax)==0)or($expmin>=$expmax)or($casas<=0)or($base<=0)) {
		   echo $msg->get("SUBPF_MSG_04")."<br><br>";
		   echo $msg->get("SUBPF_MSG_05")."<br><br>";
           echo "<form method=post enctype=multipart/form-data action=index.php?inc=subtracaoPF.php>";
		   echo "b = <input type=text size=4 maxlenght=6 name=base value=".$base."> &nbsp&nbsp ";
		   echo "m = <input type=text size=4 maxlenght=6 name=casas value=".$casas."> &nbsp&nbsp ";
		   echo "e<sub>1</sub> = <input type=text size=4 maxlenght=6 name=expmin value=".$expmin."> &nbsp&nbsp ";
		   echo "e<sub>2</sub> = <input type=text size=4 maxlenght=6 name=expmax value=".$expmax."> <br><br>";
		   echo "X<sub>1</sub> (".$msg->get("SUBPF_MSG_31").") = <input type=text size=10 maxlenght=20 name=num1 value=".$num1."> <br><br> ";
		   echo "X<sub>2</sub> (".$msg->get("SUBPF_MSG_31").") = <input type=text size=10 maxlenght=20 name=num2 value=".$num2."> <br><br>";
		   echo "<p>";
		   echo "<input class=button type=submit name=Calcular value=".$msg->get("G_MSG_04").">";
		   echo "<br>";
		   echo "</form>";
           echo "<form method=post enctype=multipart/form-data action=index.php?inc=subtracaoPF.php>";
		   echo "<input class=button type=submit name=Submit value=".$msg->get("G_MSG_03").">";
		   echo "</form>";
		}
		echo "</body>";
	}
} else {
    if ($_SESSION['ANAWEB']->RetornaModoExecucao() == "exemplo")
        verificaBib($xml_file);
    echo "<br>";
    if (!checaNumerico($base) || !checaNumerico($num1) || !checaNumerico($num2) || !checaNumerico($casas) || !checaNumerico($expmin) || !checaNumerico($expmax))
    {
?>
        <p><font color="red"><?php echo $msg->get("Apenas_Dados_Numericos") ?></font></p>
        <p><input type="button" value="<?php echo Voltar ?>" onclick="history.back()" class="button"></p>
<?php
    }
	elseif ( (strlen($base)==0)or($base<2)or($base>10)or(strlen($casas)==0)or($casas<1)or(strlen($expmin)==0)or(strlen($expmax)==0)or($expmin>=$expmax)or($casas<=0)or($base<=0)) {
       echo "<form method=post enctype=multipart/form-data action=index.php?inc=subtracaoPF.php>";
	   if ( (strlen($base)!=0) and ( ($base<2) or ($base>10) ) ) {
			  echo "<font color=red>".$msg->get("SUBPF_MSG_06")."</font>";
			  echo "<br><br>";
	   }
	   if ( (strlen($casas)!=0) and ($casas<1) ) {
			  echo "<font color=red>".$msg->get("SUBPF_MSG_07")."</font>";
			  echo "<br><br>";
	   }
	   if ( (strlen($expmin)!=0) and (strlen($expmax)!=0) and ($expmin>=$expmax) ) {
			  echo "<font color=red>".$msg->get("SUBPF_MSG_08")."</font>";
			  echo "<br><br>";
	   }
	   
	   echo "<input class=button type=submit name=Submit value=".$msg->get("G_MSG_03").">";
	   echo "</form>";
	} else { 
	   subPF($num1,$num2,$base,$casas,$expmin,$expmax);
	   echo "<p>";
       echo "<form method=post enctype=multipart/form-data action=index.php?inc=subtracaoPF.php>";
	   echo "<input class=button type=submit name=Submit value=".$msg->get("G_MSG_03").">";
	   echo "</form>";
	if (isset($_POST["navegacao"]) && $_POST["navegacao"] == "sim")
	{
	echo "<form name=\"exemplos\" enctype=\"multipart/form-data\" method=\"post\">";
	echo "<script language=\"javascript\" type=\"text/javascript\">\n";
	echo "function criarLinks(value) {\n";
	echo "document.exemplos.indice.value = value;\n";
	echo "document.exemplos.action = 'index.php?inc=subtracaoPF.php&modo=exemplo'\n";
	echo "document.exemplos.submit();\n";
	echo "}\n";
	echo "</script>";
	echo "<input type=\"hidden\" name=\"id_bib\" value=\"".$id_bib."\">";
	echo "<input type=\"hidden\" name=\"xml_file\" value=\"".$xml_file."\">";
	echo "<input type=\"hidden\" name=\"indice\">";
	echo "<br><br>".$msg->get("Outros_Exemplos")."<br>";
	//$objeto  = domxml_open_file($xml_file);
	//$raiz = $objeto->document_element();
    $objeto = DOMDocument::load($xml_file);
	$filho = $objeto->getelementsbytagname("floatingpoint");
	if ($filho->length > 0)
	{
		$temp = $filho->item(0)->getelementsbytagname("floatp");
		$j = 0;
		for($i = 0; $i < $temp->length; $i++)
		{
			$conteudo = $temp->item($i)->getelementsbytagname("decimal");
			if ($conteudo->length > 0)
			{
				if ($j != 0) echo " | ";
				if ($j == $indice) echo "<b>";
				echo "<a href=\"javascript:criarLinks($j)\"><u>".($j+1)."</u></a>";
				if ($j == $indice) echo "</b>";
				$j++;
			}
		}
	}
	}
	}   
}
?>
</div>